If File Exists Action Icon

If File Exists

Declaration

<AMIFFILEEXISTS ACTION="text [options]" FILE="text" EXCLUDE="text" ISNEWERTHAN="datetime" ISOLDERTHAN="datetime" ATTRFILTER="text [attribute mask]">

</AMIF>

See Also

Loop, The BASIC Language All Groups, Else, End If

Description

Causes the steps following this action to execute if the specified file is in the specified state. If not, execution follows the next Else or End If action, whichever comes first. Wildcards can be used.

Practical Usage

To check if a file exists (or not) and take conditional action depending on the result.

Parameters

General Tab

If
Text, Optional Default: exist)
MARKUP: ACTION="not_exist"

Specifies the type of check to be performed.

The available options are:

exist: The IF block will be executed if the file exists.

not_exist: The IF block will be executed if the file does not exist.

accessible: The IF block will be executed if the file exists and is not locked (in use by another application).

not_accessible: The IF block will be executed if the file exists and is locked (in use by another application).

Filename
Text, Required
MARKUP: FILE="c:\foldername\filename.txt"

Specifies the full path and filename to check.

Advanced Tab

Exclude Mask
Text, Optional default - (blank)
MARKUP: EXCLUDE="*.txt"

If a wildcard is specified in filename, causes the action to not check files matching the mask(s) specified. Filenames or wildcard ( e.g. * or ? ) masks may be used, multiple entries may be specified by separating them with the | symbol (e.g. *.txt|*.bak)

Only if newer than
date, Optional default - (none)
MARKUP: ISNEWERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

If a wildcard is specified in the filename, causes the action to check file(s) only if the source is newer than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored.

Only if older than
date, Optional default - (none)
MARKUP: ISOLDERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

If a wildcard is specified in the filename, causes the action to check file(s) only if the source is older than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (excluding "Only if newer" [ISNEWER] parameter).

Attributes Tab

Attributes
Text, Optional (blank)
MARKUP:
ATTRFILTER="+R+A-S-H" (delete Read Only and Archive files, not system or hidden)
ATTRFILTER="-S" (do not delete "system" files)

This group of settings causes the action to filter which files are checked based on the attribute settings of the files. In visual mode, a group of controls are provided to assist in the selection of this parameter.

In markup mode, build a single text item must be specified that contains the attributes of the files you wish to check.

Available Options:

R - Read only - Specifying "+R" causes files with this attribute turned on to be included, "-R" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

A - Archive - Specifying "+A" causes files with this attribute turned on to be included, "-A" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

S - System - Specifying "+S" causes files with this attribute turned on to be included, "-S" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

H - Hidden - Specifying "+R" causes files with this attribute turned on to be included, "-H" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

C - Compression - Specifying "+C" causes files with this attribute turned on to be included, "-C" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

Notes

Standard Error Handling Options
This action also includes the standard "Error Causes" and "On Error" failure handling options/tabs

More on Error Handling Options

Variables and Expressions
All text fields allow the use of expressions by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...

More on expressions...

More on the expression builder...

Examples

<AMIFFILEEXISTS FILE="c:\foldername\filename.txt">
<AMMESSAGEBOX>The file exists</AMMESSAGEBOX>
</AMIF>

 

 

 

.